# --- 使用最稳定、最通用的官方 Python 镜像 ---
FROM python:3.10-slim

# --- 设置环境变量，避免交互式提示 ---
ENV DEBIAN_FRONTEND=noninteractive

# --- 1. 安装系统级依赖 ---
# 更新 apt 包列表，安装基础工具
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    # --- 清理 apt 缓存 ---
    && rm -rf /var/lib/apt/lists/*

# --- 2. 设置工作目录并安装 Python 依赖 ---
WORKDIR /app

COPY requirements.txt .

RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# --- 3. 复制应用代码 ---
COPY . .

# --- 4. 设置环境变量并暴露端口 ---
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH=/app

# --- 5. 容器启动命令 ---
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
